package selenium.demo;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import static java.lang.Thread.sleep;

/**
 * @Author quan
 * @Description 清除
 * @Date 2023/8/14 11:32
 */
public class Demo4_Clear {
    public static void main(String[] args) throws InterruptedException {
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");
        WebDriver webDriver = new ChromeDriver(options);
        webDriver.get("https://www.baidu.com/");
        //1-首先输入“音乐”
        //找到输入框输入音乐-找到百度一下按钮并点击
        webDriver.findElement(By.cssSelector("#kw")).sendKeys("音乐");
        webDriver.findElement(By.cssSelector("#su")).click();
        sleep(100);
        //2-找到输入框-清除该内容
        webDriver.findElement(By.cssSelector("#kw")).clear();
        sleep(100);
        //3-找到输入框—重新输入“天气”-点击百度一下按钮
        webDriver.findElement(By.cssSelector("#kw")).sendKeys("天气");
        webDriver.findElement(By.cssSelector("#su")).click();
    }
}
